<template>
	<view class="content">
		<view class="list">
			<view class="item" v-for="item in list" @click="goCouponList(item)">
				<image :src="item.images[0]" mode=""></image>
				<view class="box">
					<view class="name">
						{{item.name}}
					</view>
					<view class="address">
						{{item.address}}
					</view>
					<view class="distance">
						{{item.juli}}km
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				couponId:"",
			}
		},
		onShow() {
			this.getLocation();
		},
		onLoad(options) {
			this.couponId = options.couponId;
			if(options.scene){
				uni.setStorageSync('scene', options.scene);
			}
			console.log(options.scene)
		},
		methods: {
			getLocation(){
				uni.getLocation({
					type: 'wgs84',
					success: (res) => {
						console.log(res)
						this.longitude = res.longitude;
						this.latitude = res.latitude;
						this.getList()
					}
				});
			},
			goDetail(item) {
				console.log(item)
				uni.navigateTo({
					url: `/pages/shop/detail?shopId=${item.id}&couponId=${this.couponId}`
				})
			},
			goCouponList(item){
				uni.navigateTo({
					url: `/pages/index/index?shopId=${item.id}`
				})
			},
			noPage() {
				uni.showToast({
					title: "功能开发中！",
					icon: "none"
				})
			},
			getList() {
				this.$get('shop/shoplist', {page:1,pagesize:1000,lat:this.latitude,lng:this.longitude}, (res) => {
					this.list = res
				})
			},
		},
		onShareAppMessage(){
			
		}
	}
</script>

<style>
	page {
		padding: 0 20rpx;
		box-sizing: border-box;
	}

	.list {
		
	}
	
	.list .item{
		width: 700rpx;
		margin: 20rpx auto;
		background-color: #FFFFFF;
		border-radius: 26rpx;
		padding: 30rpx;
	}
	.list .item .box{
		position: relative;
		width: calc(100% - 150rpx);
		float: right;
		padding-left: 20rpx;
	}

	.list .item image {
		width: 148rpx;
		height: 148rpx;
		border-radius: 14rpx;
	}
	.list .item .name{
		font-size: 34rpx;
		margin-bottom: 20rpx;
		color: #111111;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		margin-top: 10rpx;
	}
	.list .item .address{
		font-size: 26rpx;
		color: #666666;
		width: calc(100% - 150rpx);
		line-height: 35rpx;
		overflow: hidden;
		-webkit-line-clamp: 2;
		text-overflow: ellipsis;
		-webkit-box-orient: vertical;
		display: -webkit-box;
	}
	.list .item .distance{
		font-size: 26rpx;
		color: #666666;
		position: absolute;
		right: 20rpx;
		top: 60rpx;
	}
</style>
